//定点抛物线

//代码示例： parabola(obj, {x: 700, y: 300}, 2000, function(){});

function parabola(ele, target, time, callback){
	//计算原点坐标
	var centerPoint = {
		x : ele.offsetLeft,
		y : ele.offsetTop
	}
	//终点坐标
	var endPoint = {
		x : target.x - centerPoint.x,
		y : target.y - centerPoint.y
	}
	
	//计算曲线方程系数
	var a = 0.001;
	var b = (endPoint.y - a*endPoint.x*endPoint.x)/endPoint.x;
	
	//计算运动频率
	var hz= Math.ceil(5*time/endPoint.x); 
	
	//定点抛物线运动
	var x = 0;
	ele.timer = setInterval(function(){
		ele.style.left = centerPoint.x + (x+=5) + "px";
		ele.style.top = centerPoint.y + a*x*x + b*x + "px";
		if(ele.offsetLeft >= target.x) {
			ele.style.left = target.x + "px";
			ele.style.top = target.y + "px";
			clearInterval(ele.timer);
			callback ? callback() : "";//执行回调函数
		}
	},hz);
}
